<?php

use App\Kuafu\Customer\Controller\Internal\CustomerActionController;
use App\Kuafu\Dashboard\Controller\Merchant\IndexController;
use App\Kuafu\Export\Controller\B\ExportDownloadsController;
use App\Kuafu\Mybank\Controller\Internal\MybankController;
use App\Kuafu\Order\Controller\Internal\OrderController;
use App\Kuafu\ProductMenu\Controller\Internal\ProductMenuController;
use App\Kuafu\Shop\Controller\B\AreaController;
use App\Kuafu\Shop\Controller\Internal\CameraController;
use App\Kuafu\Shop\Controller\Merchant\ShopStatisticsController;
use App\Kuafu\User\Controller\Internal\CacheController;
use App\Kuafu\User\Controller\Internal\UserController;
use App\Kuafu\User\Enum\UserCodeEnum;
use Illuminate\Support\Facades\Route;
use App\Kuafu\Pay\Controller\Internal\PayController;
use App\Http\Middleware\InternalApiAuth;
use App\Kuafu\Shop\Controller\Internal\ShopController;
use App\Kuafu\User\Controller\Internal\PermissionsController;
use App\Kuafu\User\Controller\Internal\LoginController as FeishuLoginController;
use App\Kuafu\User\Controller\Internal\FsUserController;

Route::group(['middleware' => InternalApiAuth::class], function () {
    Route::prefix("shop")->group(function () {
        Route::get('shopListByUserId', [ShopController::class, 'shopListByUserId']);
        Route::post('getUserInfoToPush', [UserController::class, 'getInfo']);
        Route::get('getFormalUseShopLists', [ShopController::class, 'getFormalUseShopLists']);
        Route::post('create', [ShopController::class, 'create']);
        Route::get('getShopByCode', [ShopController::class, 'getShopByCode']);
        Route::get('getShopByCodes', [ShopController::class, 'getShopByCodes']);
        Route::get('getShopInfo', [ShopController::class, 'getShopInfo']);
        Route::get('getShopInfos', [ShopController::class, 'getShopInfos']);
        Route::get('getOpenShopInfo', [ShopController::class, 'getOpenShopInfo']); // 开业信息
        Route::get('getStartBusinessData', [ShopController::class, 'getStartBusinessData']); // N天开业数据
        Route::post('updateShopField', [ShopController::class, 'updateShopField']);
        Route::get('checkOpenShopCode', [ShopController::class, 'checkOpenShopCode']); // 校验开店填入的shopCode
        Route::get('overviewByProvinceCodes', [ShopController::class, 'overviewByProvinceCodes']); // 根据省区统计
        Route::get('functionOpenDetail', [ShopController::class, 'getShopFunctionOpenDetail']); // 功能开通
        Route::post("synchronizeShopInfo", [ShopController::class, 'synchronizeShopInfo']);//选址完成同步门店信息
        Route::post("switchShopOn", [ShopController::class, 'switchShopOn']);//凑备确认施工完成，门店启用
        Route::post("closeShop", [ShopController::class, 'closeShop']);//闭店
        Route::post("updateShopMobile", [ShopController::class, 'updateShopMobile']);//修改门店手机号
        Route::get("cityShop", [ShopController::class, 'cityShop']);//城市门店列表
        Route::get('getShopByName', [ShopController::class, 'getShopByName']); // 通过名称查询门店信息

        Route::get('cruiseShopFilter', [ShopController::class, 'cruiseShopFilter']); // 稽核门店范围筛选
        Route::get('shopBusiness', [ShopController::class, 'shopBusiness']); // 风云榜
        Route::get("getShopInfoByLikeSearch", [ShopController::class, 'getShopInfoByLikeSearch']);//门店模糊查询
        Route::get("getShopList", [ShopController::class, 'getShopList']);//门店模糊查询

        Route::get('getShopStaffListByShopId', [ShopController::class, 'getShopStaffListByShopId']); //根据门店ID获得门店员工

        Route::post('unbindFunctionOpen', [ShopController::class, 'unbindFunctionOpen']); // 解绑功能开通
        Route::get('getShopDetailByShopId', [ShopController::class, 'getShopDetailByShopId']); // 根据门店id获取门店详细信息

        Route::get('/windCloud', [ShopStatisticsController::class, 'getWindCloudRank']);// 门店风云榜
        Route::get('/dashboard/cruise', [IndexController::class, 'index']);//营业指标数据
        Route::post('/shopFuYouPaymentsEdit/{shopId}/{paymentId}',
            [ShopController::class, 'shopFuYouPaymentsEdit']);//门店富有支付配置新增
        Route::get('/getShopAttribute', [ShopController::class, 'getShopAttribute']);// 查询门店属性
        Route::post('/updateShopAttribute/{shopId}', [ShopController::class, 'updateShopAttribute']);// 编辑门店属性
        Route::get('/getShopAttributeData', [ShopController::class, 'getShopAttributeData']);// 查询门店属性配置项

        Route::post('syncGuanYuanShopList', [
            \App\Kuafu\Shop\Controller\Internal\GuanyuanSyncShopListController::class,
            'syncGuanYuanShopList'
        ]);// 同步观远门店数据
    });

    // 支付
    Route::prefix('pay')->group(function () {
        Route::post('directAppPay', [PayController::class, 'directAppPay']); // app直连支付
        Route::post('closePay', [PayController::class, 'closePay']); // 关闭支付
        Route::post('directAppRefund', [PayController::class, 'directAppRefund']); // 退款
        Route::post('wapPay', [PayController::class, 'wapPay']); // h5支付
        Route::post('nativePay', [PayController::class, 'nativePay']); // 网页二维码支付

        Route::any('addFyConfig', [PayController::class, 'addFyConfig']); // 新增富友配置
        Route::post('addMyBankShareConfig', [PayController::class, 'addMyBankShareConfig']); // 新增网商分账配置
        Route::post('delFyConfig', [PayController::class, 'delFyConfig']); // 删除富友配置
        Route::any('payDetails', [PayController::class, 'payDetails']); // 批量查询支付详情
        Route::get('payResult', [PayController::class, 'payResult']); // 支付结果
        Route::get('getCheckFileUrl', [PayController::class, 'getCheckFileUrl']); // 获取对账文件地址
    });

    // 权限相关
    Route::group(['prefix' => 'dashboard'], function () {
        Route::get('shops', [\App\Kuafu\Dashboard\Controller\Internal\DashboardController::class, 'shops']);
        Route::get('permissions', [\App\Kuafu\Dashboard\Controller\Internal\DashboardController::class, 'permissions']);
    });

    // DEMO
    Route::get('demo', [PayController::class, 'demo']);

    //openShop
    Route::prefix('openShop')->group(function () {
        Route::post('login', [FeishuLoginController::class, 'login']);
        Route::post('/verifyCode', [FeishuLoginController::class, 'verifyCode']);
    });

    // 用户信息
    Route::prefix('user')->group(function () {
        Route::get("/getUserListByPower", [UserController::class, 'getUserListByPower']);
        Route::get("/getUserInfoByIds", [UserController::class, 'getUserInfoByIds']);
        Route::get("/getRegistrationIdByIds", [UserController::class, 'getRegistrationIdByIds']);
        Route::get("/getWebUserList", [UserController::class, 'getWebUserList']);
        Route::get('/getRmsUserIdByUserName', [UserController::class, 'getRmsUserIdByUserName']);// 模糊查询用户名称
        Route::get("/getSiteTaskHandlerList", [UserController::class, 'getSiteTaskHandlerList']);
        Route::get("/getShopOwnerCount", [UserController::class, 'getShopOwnerCount']);

        Route::get("/getAuthInfo", [UserController::class, 'getAuthInfo'])
             ->middleware(['jwtAuth:' . UserCodeEnum::WEB_TYPE, 'common.headerAuth', 'common.userPermissionAuth']);

        // 解析 JWT
        Route::post("/decodeJwt", [UserController::class, 'decodeJwt']);


        // 获取用户的登录信息
        Route::get("/getAuthUserInfo", [UserController::class, 'getAuthUserInfo']);
        Route::post('/loginByPassword', [UserController::class, 'loginByPassword']);

        Route::get('/getUserInfoByMobiles', [UserController::class, 'getUserInfoByMobiles']);
        Route::post('/setUserInfoById', [UserController::class, 'setUserInfoById']);
        Route::post('/create', [UserController::class, 'create']);
        Route::get('/getInfoByUsernames', [UserController::class, 'getInfoByUsernames']);
        Route::get("/getRoleUserLists", [UserController::class, 'getRoleUserLists']);

        // 员工档案缺失门店
        Route::get("/getProblemShopStaffList", [UserController::class, 'getProblemShopStaffList']);

        // 获取店长列表
        Route::get("/getShopManagerUserLists", [UserController::class, 'getShopManagerUserLists']);
        Route::get("/getShopManagerUserByShopId", [UserController::class, 'getShopManagerUserByShopId']);
        Route::get('/getShopIdsByUserManager', [UserController::class, 'getShopIdsByUserManager']);

        // 获取用户列表
        Route::get("/getNotifyAllUserLists", [UserController::class, 'getNotifyAllUserLists']);

        Route::get("/isRoleUser", [UserController::class, 'isRoleUser']);
        Route::get('/getUserPermission', [UserController::class, 'getUserPermission']);

        // roleId枚举
        Route::get('/roleIdsConfig', [UserController::class, 'roleIdsConfig']);
        //获取用户角色
        Route::get('/role', [UserController::class, 'role']);

        // 通过职位模糊查询用户列表
        Route::get('/getUsersByRoleName', [UserController::class, 'getUsersByRoleName']);

        // 获得拥有店长权限并且没有开通网商银行的门店的用户列表
        Route::get('/getNoPowerWalletByProvince', [UserController::class, 'getNoPowerWalletByProvince']);

        // 商家APP登录获取JWT
        Route::post('/getMerchantLoginJwt', [UserController::class, 'getMerchantLoginJwt']);

        // 门店的关联用户列表
        Route::get('usersInShop', [UserController::class, 'usersInShop']);
        // 门店的关联用户
        Route::get('usersInShops', [UserController::class, 'usersInShops']);

        // 导入品控服务商员工
        Route::post('importSupplierCruiseStaff', [UserController::class, 'importSupplierCruiseStaff']);
    });

    Route::prefix('fsUser')->group(function () {
        Route::get('/getUserLists', [FsUserController::class, 'getUserLists']);
        Route::get('/getUserListByIds', [UserController::class, 'getFsUserByUserIds']);//获取飞书用户信息
    });

    // 系统
    Route::prefix('sys')->group(function () {
        Route::get('/getAllPermission', [PermissionsController::class, 'getAllPermission']);
        Route::post('/rmCache', [CacheController::class, 'rmCache']);
        Route::get('/getConfig', [\App\Kuafu\Config\Controller\Internal\ConfigController::class, 'getConfig']);
    });
    // 菜品菜单
    Route::prefix('productMenu')->group(function () {
        Route::get('/getAllById', [ProductMenuController::class, 'getAllById']);
    });

    //根据省市区获得
    Route::get('getAreaCodeByArea', [\App\Kuafu\Common\Controller\Internal\AreaController::class, 'getAreaCodeByArea']);

    //MQTT发送
    Route::post('sendMqtt', [\App\Kuafu\Mqtt\Controller\MqttController::class, 'index']);

    // 订单管理
    Route::prefix('order')->group(function () {
        Route::get('/orderDetailList',
            [OrderController::class, 'orderDetailList']);
        Route::get('/originalPrice', [OrderController::class, 'originalPrice']);
        Route::get('/combineOrderList',
            [\App\Kuafu\Order\Controller\Merchant\OrderController::class, 'combineOrderList']);
        Route::get('waiMaiToken', [OrderController::class, 'waiMaiToken']);
        Route::get('indexCharts', [IndexController::class, 'indexCharts']);
    });

    // robot
    Route::prefix('robot')->group(function () {

        // 发送rms机器人消息
        Route::post('/sendChatMessage', [\App\Kuafu\Robot\Controller\Feishu\RmsController::class, 'sendChatMessage']);
    });

    // area
    Route::prefix('area')->group(function () {

        Route::get('getCityGrade', [AreaController::class, 'getCityGrade']);
        //获取所有的省市区
        Route::get('/list', [AreaController::class, 'areaListAll']);
    });

    // 导出处理
    Route::prefix('export')->group(function () {
        Route::post('/add', [ExportDownloadsController::class, 'remoteExportAdd']);//创建
        Route::post('/finish', [ExportDownloadsController::class, 'remoteExportFinish']);//完成
    });

    // 网商
    Route::prefix('mybank')->group(function () {
        // 获取抽佣配置
        Route::get('/getBrokerageConfig', [MybankController::class, 'getBrokerageConfig']);
        // 余额
        Route::get('/balance', [MybankController::class, 'balance']);
        // 注册状态
        Route::get('/registerStatus', [MybankController::class, 'registerStatus']);
        // 注册
        Route::post("/register", [\App\Kuafu\Mybank\Controller\MybankEntryController::class, "create"]);
        // 账户详情：注册状态、余额
        Route::get('/accountDetail', [MybankController::class, 'accountDetail']);
    });

    Route::prefix('camera')->group(function () {
        //门店摄像头列表
        Route::get('/shopCamera', [CameraController::class, 'shopCamera']);
    });

    Route::prefix('customer')->group(function () {
        // 新增用户操作记录
        Route::post('/addCustomerActionLog', [CustomerActionController::class, 'addCallingCardAction']);
        Route::get('/getCustomerPlatformUsers', [CustomerActionController::class, 'getCustomerPlatformUsers']);// 获取用户信息
    });

    // 接口调用记录
    Route::prefix('apiTime')->group(function () {
        Route::get('/batchLists', [\KuafuComposer\ApiTime\Controller\ApiTimeController::class, 'batchLists']);
    });
});



